﻿using System.Collections.Generic;

namespace DL.AI.AIBT
{
    //行为树节点
    public class BTNode
    {
       
        public readonly string name;
        public readonly int Priority;
        
        public readonly List<BTNode> Children;
        protected int m_CurrentChild;

        public BTNode(string name = "BTNode",int priority = 0)
        {
            Priority = priority;
            this.name = name;
            Children = new();
        }

        public void AddChild(BTNode node) => Children.Add(node);
        
        //在Update中执行
        public virtual Status Process() => Children[m_CurrentChild].Process();

        public virtual void Reset()
        {
            m_CurrentChild = 0;
            foreach (var child in Children)
            {
                child.Reset();
            }
        }
    }

}